import './index.scss'
import React, { Component } from 'react'
import { NavBar } from 'antd-mobile';
import { withRouter } from 'react-router-dom';
import PropTypes from 'prop-types';

class NavHeader extends Component {
  static propTypes = {
    children: PropTypes.string.isRequired,
    onLeftClick: PropTypes.func
  }

  render() {
    return (
      <NavBar
        className="navbar"
        mode="light"
        icon={<span className="iconfont icon-back" />}
        rightContent={this.props.rightContent || ''}
        onLeftClick={this.props.onLeftClick ? this.props.onLeftClick : () => this.props.history.go(-1)}
      >{this.props.children}</NavBar>
    )
  }
}
// 需要使用 withRouter 才能拿到路由属性
export default withRouter(NavHeader);